
//雇主详情完善信息
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:get/get.dart';
import 'package:get/get_core/src/get_main.dart';
import 'package:untitled1/app/res/myColors.dart';
import 'package:untitled1/app/utils/utilDialog.dart';
import 'package:untitled1/app/widgets/TitleBar.dart';
import 'package:untitled1/app/widgets/base_page/BaseStatefulPage.dart';


import '../../../utils/utilScreen.dart';
import '../../../widgets/TextSelector.dart';
import '../serve/ServeJobUpdateController.dart';

//求职意向
class PersonalInfoPage extends BaseStatefulPage {
  @override
  BaseStatefulPageState<BaseStatefulPage> createState() {
    return _PersonalInfoPageState();
  }
}

class _PersonalInfoPageState  extends BaseStatefulPageState<PersonalInfoPage> {
  final ServeJobUpdateController controllerData = Get.put(
    ServeJobUpdateController(),
  );


  var gender = '';

  @override
  Widget buildPage(BuildContext context) {
    return Scaffold(
      appBar: TitleBar(title: "个人信息"),
      body: Container(
        color: myColors.c_bg,
        child: Column(
          children: [
            Expanded(
              child: SingleChildScrollView(
                child: Column(
                  children: [
                    buildAvatarItem(),
                    // buildItemTextField2(
                    //     '编号', controllerData.shoujiaho, isRequired: false),

                    Divider(height: 1, color: myColors.c_divider),
                    buildItemTextField2(
                        '姓名', controllerData.xingming, isRequired: true),
                    Divider(height: 1, color: myColors.c_divider),
                    buildItemTextField2(
                        '昵称', controllerData.xingming, isRequired: true),
                    Divider(height: 1, color: myColors.c_divider),
                    buildItemTextField('自我介绍', controllerData.ziwojieshao),
                    Divider(height: 1, color: myColors.c_divider),
                    buildItem(
                      '出生日期',
                      controllerData.chushengriq,
                      isRequired: true,
                      onTapFunction: () {
                        controllerData.chushengriq.value = '男';
                      },
                    ),
                    Divider(height: 1, color: myColors.c_divider),
                    buildItem(
                      '居住地址',
                      controllerData.chushengriq,
                      isRequired: true,
                      onTapFunction: () {
                        controllerData.chushengriq.value = '男';
                      },
                    ),
                    Divider(height: 1, color: myColors.c_divider),
                    buildItemTextField('详细地址', controllerData.ziwojieshao),
                    Divider(height: 1, color: myColors.c_divider),
                    buildItem(
                      '性别',
                      controllerData.chushengriq,
                      isRequired: true,
                      onTapFunction: () {
                        controllerData.chushengriq.value = '男';
                      },
                    ),
                    Divider(height: 1, color: myColors.c_divider),
                    buildItem(
                      '学历',
                      controllerData.chushengriq,
                      isRequired: true,
                      onTapFunction: () {
                        controllerData.chushengriq.value = '男';
                      },
                    ),
                    Divider(height: 1, color: myColors.c_divider),
                    buildItem(
                      '民族',
                      controllerData.chushengriq,
                      isRequired: true,
                      onTapFunction: () {
                        controllerData.chushengriq.value = '男';
                      },
                    ),
                    Divider(height: 1, color: myColors.c_divider),
                    buildItem(
                      '工作方式',
                      controllerData.chushengriq,
                      isRequired: true,
                      onTapFunction: () {
                        controllerData.chushengriq.value = '男';
                      },
                    ),
                    //
                    //
                    //
                    //
                    //
                    // Divider(height: 1, color: myColors.c_divider),
                    //
                    //
                    //
                    //
                    //
                    // buildItemTextField2(
                    //     '工作年限(年)', controllerData.gognzuonianxian),
                    // Divider(height: 1, color: myColors.c_divider),
                    // buildItemTextField2(
                    //     '家政经验(年)', controllerData.gognzuonianxian,
                    //     isRequired: true),
                    // Divider(height: 1, color: myColors.c_divider),
                    // buildItem(
                    //   '出生日期',
                    //   controllerData.chushengriq,
                    //   isRequired: true,
                    //   onTapFunction: () {
                    //     controllerData.chushengriq.value = '男';
                    //   },
                    // ),
                    // Divider(height: 1, color: myColors.c_divider),
                    // buildItem(
                    //   '性别',
                    //   controllerData.xingbie,
                    //   isRequired: true,
                    //   onTapFunction: () {
                    //     controllerData.xingbie.value = '男';
                    //   },
                    // ),
                    //
                    // Divider(height: 1, color: myColors.c_divider),
                    // buildItem(
                    //   '籍贯',
                    //   controllerData.jiguan,
                    //   isRequired: true,
                    //   onTapFunction: () {
                    //     controllerData.jiguan.value = '男';
                    //   },
                    // ),
                    // Divider(height: 1, color: myColors.c_divider),
                    // buildItem(
                    //   '学历',
                    //   controllerData.xueli,
                    //   isRequired: false,
                    //   onTapFunction: () {
                    //     controllerData.xueli.value = '男';
                    //   },
                    // ),
                    // Divider(height: 1, color: myColors.c_divider),
                    // buildItem(
                    //   '属相',
                    //   controllerData.shuxiang,
                    //   isRequired: false,
                    //   onTapFunction: () {
                    //     controllerData.shuxiang.value = '男';
                    //   },
                    // ),
                    // Divider(height: 1, color: myColors.c_divider),
                    // buildItem(
                    //   '星座',
                    //   controllerData.xingzuo,
                    //   isRequired: false,
                    //   onTapFunction: () {
                    //     controllerData.xingzuo.value = '男';
                    //   },
                    // ),
                    //
                    // Divider(height: 1, color: myColors.c_divider),
                    // buildItemTextField2("身高", controllerData.shengao),
                    // Divider(height: 1, color: myColors.c_divider),
                    // buildItem(
                    //   '民族',
                    //   controllerData.minzu,
                    //   isRequired: false,
                    //   onTapFunction: () {
                    //     controllerData.minzu.value = '男';
                    //   },
                    // ),
                    // Divider(height: 1, color: myColors.c_divider),
                    // buildItem(
                    //   '宗教信仰',
                    //   controllerData.zongjiaoxinyang,
                    //   isRequired: false,
                    //   onTapFunction: () {
                    //     controllerData.zongjiaoxinyang.value = '男';
                    //   },
                    // ),
                    // Divider(height: 1, color: myColors.c_divider),
                    // buildItem(
                    //   '地址',
                    //   controllerData.dizhi,
                    //   isRequired: false,
                    //   onTapFunction: () {
                    //     controllerData.dizhi.value = '男';
                    //   },
                    // ),
                    // Divider(height: 1, color: myColors.c_divider),
                    // buildItemTextField2(
                    //     "详细地址", controllerData.xinagxidizhi),
                    // Divider(height: 1, color: myColors.c_divider),
                    // buildItem(
                    //   '档期时间',
                    //   controllerData.dangqishijian,
                    //   isRequired: true,
                    //   onTapFunction: () {
                    //     controllerData.dangqishijian.value = '男';
                    //   },
                    // ),
                    // Divider(height: 1, color: myColors.c_divider),
                    // buildItem(
                    //   '服务雇主数',
                    //   controllerData.dangqishijian,
                    //   isRequired: true,
                    //   onTapFunction: () {
                    //     controllerData.dangqishijian.value = '男';
                    //   },
                    // ),
                    //
                    // Divider(height: 1, color: myColors.c_divider),
                    // buildItem(
                    //   '语言',
                    //   controllerData.yuyan,
                    //   isRequired: true,
                    //   onTapFunction: () {
                    //     controllerData.yuyan.value = '男';
                    //   },
                    // ),


                  ],
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }

  // 头像组件
  Widget buildTitle(String title) {
    return Container(
      alignment: Alignment.centerLeft,
      height: 40,
      margin: const EdgeInsets.symmetric(horizontal: 15),
      child: Text(
        title,
        style: TextStyle(color: myColors.c_191919, fontWeight: FontWeight.bold),
      ),
    );
  }

  // 通用信息项
  Widget buildItem(String title,
      RxString value, {
        bool showArrow = true,
        int maxLines = 1,
        bool isRequired = false, Color bgcolor = Colors.white,
        Function()? onTapFunction,
      }) {
    return Obx(
          () =>
          Container(
              height: 40,
              color: bgcolor,
              padding: const EdgeInsets.only(left: 15, right: 15),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Row(
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: [
                      if (isRequired)
                        Text(
                          "*",
                          style: TextStyle(
                            color: Colors.red,
                            fontSize: 12,
                            fontWeight: FontWeight.bold,
                          ),
                        ),
                      Text(
                        "${title}:",
                        style: const TextStyle(
                            fontSize: 14, color: myColors.c_191919),
                      ),
                    ],
                  ),
                  Expanded(child: InkWell(
                    onTap: () {
                      if (onTapFunction == null) {
                        return;
                      }
                      // setState(() {
                      onTapFunction();
                      print('>]aaaaaaa  value=${value}');
                      // });
                    },
                    child: Container(
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.end,
                        children: [
                          if (value.value != null)
                            Text(
                              value.value,
                              maxLines: maxLines,
                              overflow: TextOverflow.ellipsis,
                              style: const TextStyle(color: Colors.black),
                            ),
                          if (showArrow) const SizedBox(width: 10),
                          if (showArrow) const Icon(
                              Icons.arrow_forward_ios, size: 16),
                        ],
                      ),
                    ),
                  ))
                ],
              )
          ),
    );
  }

  Widget buildItemTextField2(String title, RxString value,
      {bool isRequired = false}) {
    final TextEditingController _controller = TextEditingController(
        text: value.value);
    return Container(
      color: myColors.white,
      height: 40,
      padding: EdgeInsets.only(left: 15, right: 15),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          if (isRequired)Text(
            "*",
            style: TextStyle(
              color: Colors.red,
              fontSize: 12,
              fontWeight: FontWeight.bold,
            ),
          ),
          Text(
            "${title}：",
            style: const TextStyle(fontSize: 14, color: myColors.c_191919),
          ),
          Expanded(
            child: TextField(
              controller: _controller,
              // 控制器绑定
              textAlign: TextAlign.right,
              //字体样式
              style: TextStyle(fontSize: 14, color: myColors.c_191919),
              maxLines: 1,
              // 显示1行，null：自动换行
              decoration: InputDecoration(
                hintText: '请输入内容',
                // 设置提示语
                border: InputBorder.none,
                // 移除所有边框
                //把边距都设置0
                contentPadding: EdgeInsets.symmetric(
                    vertical: 0, horizontal: 0),
                filled: false,
                //显示填充颜色
                isDense: true, //（上下居中） 紧凑模式，防止多余的内边距
              ),
              onChanged: (text) {
                value.value = text;
              },
            ),
          ),
        ],
      ),
    );
  }

  Widget buildItemTextField(String title, RxString value) {
    final TextEditingController _controller = TextEditingController(
        text: value.value);
    return Container(
      color: myColors.white,
      padding: EdgeInsets.only(left: 15, right: 15, top: 10, bottom: 10),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Text(
            title,
            style: const TextStyle(fontSize: 14, color: myColors.c_191919),
          ),
          SizedBox(
            height: 60,
            width: utilScreen.getScreenWidth(context),
            child: TextField(
              controller: _controller,
              // 控制器绑定
              style: TextStyle(fontSize: 14, color: myColors.c_191919),
              maxLines: null,
              // 没有限制行数 → 自动换行
              decoration: InputDecoration(
                hintText: '请输入内容', // 设置提示语
                border: InputBorder.none, // 移除所有边框
              ),
              onChanged: (text) {
                value.value = text;
              },
            ),
          ),
        ],
      ),
    );
  }

  Widget buildAvatarItem() {
    return Container(
      color: Colors.white,
      padding: const EdgeInsets.symmetric(vertical: 12),
      child: ListTile(
        title: const Text('头像', style: TextStyle(fontSize: 16)),
        trailing: Row(
          mainAxisSize: MainAxisSize.min,
          children: const [
            CircleAvatar(
              radius: 30,
              backgroundImage:
              NetworkImage(
                  'https://avatars.githubusercontent.com/u/583231?v=4'),
            ),
            SizedBox(width: 10),
            Icon(Icons.arrow_forward_ios, size: 16),
          ],
        ),
        onTap: () {
          // TODO: 更换头像逻辑
        },
      ),
    );
  }
}





// import 'package:flutter/material.dart';
// import 'package:untitled1/app/res/myColors.dart';
//
// // 个人信息
// class PersonalInfoPage extends StatelessWidget {
//   const PersonalInfoPage({super.key});
//
//   @override
//   Widget build(BuildContext context) {
//     return Scaffold(
//       appBar: AppBar(
//         title: const Text('个人信息'),
//         centerTitle: true,
//         backgroundColor: Colors.white,
//         foregroundColor: Colors.black,
//         elevation: 0.5,
//       ),
//       backgroundColor: const Color(0xFFF2F2F2),
//       body: ListView(
//         children: [
//           buildAvatarItem(),
//           buildItem('昵称', '昵称'),
//           Divider(height: 1,color: myColors.divider,),
//           buildItem('编号', 'xxxx', showArrow: false),
//           buildQRCodeItem(),
//           buildItem('更多信息', '', hasValue: false),
//           buildItem('性别', '男'),
//           buildItem('地区', '广东 深圳'),
//           buildItem('个性签名', '这家伙很懒，什么都没写~', maxLines: 1),
//         ],
//       ),
//     );
//   }
//
//   // 头像组件
//   Widget buildAvatarItem() {
//     return Container(
//       color: Colors.white,
//       padding: const EdgeInsets.symmetric(vertical: 12),
//       child: ListTile(
//         title: const Text('头像', style: TextStyle(fontSize: 16)),
//         trailing: Row(
//           mainAxisSize: MainAxisSize.min,
//           children: const [
//             CircleAvatar(
//               radius: 30,
//               backgroundImage:
//               NetworkImage('https://avatars.githubusercontent.com/u/583231?v=4'),
//             ),
//             SizedBox(width: 10),
//             Icon(Icons.arrow_forward_ios, size: 16),
//           ],
//         ),
//         onTap: () {
//           // TODO: 更换头像逻辑
//         },
//       ),
//     );
//   }
//
//   // 通用信息项
//   Widget buildItem(String title, String value,
//       {bool showArrow = true, bool hasValue = true, int maxLines = 1,GestureTapCallback? onTap}) {
//     return Container(
//       color: Colors.white,
//       padding: const EdgeInsets.symmetric(vertical: 0),
//       child: ListTile(
//         title: Text(title, style: const TextStyle(fontSize: 16)),
//         trailing: Row(
//           mainAxisSize: MainAxisSize.min,
//           children: [
//             if (hasValue)
//               Text(
//                 value,
//                 maxLines: maxLines,
//                 overflow: TextOverflow.ellipsis,
//                 style: const TextStyle(color: Colors.grey),
//               ),
//             if (showArrow) const SizedBox(width: 10),
//             if (showArrow) const Icon(Icons.arrow_forward_ios, size: 16),
//           ],
//         ),
//         onTap: () {
//           onTap;
//         },
//       ),
//     );
//   }
//
//   // 我的二维码
//   Widget buildQRCodeItem() {
//     return Container(
//       color: Colors.white,
//       child: ListTile(
//         title: const Text('我的二维码', style: TextStyle(fontSize: 16)),
//         trailing: Row(
//           mainAxisSize: MainAxisSize.min,
//           children: const [
//             Icon(Icons.qr_code, color: Colors.grey),
//             SizedBox(width: 5),
//             Icon(Icons.arrow_forward_ios, size: 16),
//           ],
//         ),
//         onTap: () {
//           // TODO: 跳转二维码页面
//         },
//       ),
//     );
//   }
// }
